package com.bcgtgjyb.huanwen.customview.customview.slice;

import com.bcgtgjyb.huanwen.customview.customview.ResourceTable;
import com.bcgtgjyb.huanwen.customview.mylibrary.TaiJiButton;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

/**
 * MainAbilitySlice 类
 *
 * @since 2021-05-07
 */
public class MainAbilitySlice extends AbilitySlice {
    private TaiJiButton taiJiButton;
    private Button button;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        taiJiButton = (TaiJiButton) findComponentById(ResourceTable.Id_taiJiButton);
        button = (Button) findComponentById(ResourceTable.Id_button);
        taiJiButton.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if (!taiJiButton.isLoading()) {
                    taiJiButton.startLoad();
                }
            }
        });
        button.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                if (taiJiButton.isLoading()) {
                    taiJiButton.stopLoad();
                }
            }
        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
